package com.seed.launcher.listener.bean;

import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;

import androidx.annotation.Keep;

import java.util.Objects;

/**
 * 蓝牙信息
 *
 * @author xct
 * create on: 2022/8/31 11:24
 */
@Keep
public class BluetoothInfo {

    public String name;
    public String address;
    public boolean isConn;
    //信号强度
    public int rssi;

    //10:none, 11:bounding, 12:bounded
    public int boundState;
    //最近一次被扫描到的时间
    public long timestamp;

//    public static final int DEVICE_TYPE_UNKNOWN = 0;

    /**
     * Bluetooth device type, Classic - BR/EDR devices
     */
//    public static final int DEVICE_TYPE_CLASSIC = 1;

    /**
     * Bluetooth device type, Low Energy - LE-only
     */
//    public static final int DEVICE_TYPE_LE = 2;

    /**
     * Bluetooth device type, Dual Mode - BR/EDR/LE
     */
//    public static final int DEVICE_TYPE_DUAL = 3;
    public int type;


    public boolean isBounded() {
        return boundState == BluetoothDevice.BOND_BONDED;
    }

    public boolean isConn() {
        return isConn;
    }

    @Override
    public String toString() {
        return "BluetoothInfo{" +
                "name='" + name + '\'' +
                ", address='" + address + '\'' +
                ", isConn=" + isConn +
                ", rssi=" + rssi +
                ", boundState=" + boundState +
                ", type=" + type +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof BluetoothInfo)) return false;
        BluetoothInfo that = (BluetoothInfo) o;
        return isConn == that.isConn
                && rssi == that.rssi
                && boundState == that.boundState
                && name.equals(that.name)
                && address.equals(that.address);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, address, isConn, rssi, boundState);
    }
}
